package com.eastfair.venuebooking.service;

import com.eastfair.boot.service.SuperService;
import com.eastfair.core.base.R;
import com.eastfair.venuebooking.dto.*;
import com.eastfair.venuebooking.entity.FollowRecord;
import com.eastfair.venuebooking.vo.FollowRecordTimelineVO;
import com.eastfair.venuebooking.vo.FollowRecordVO;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 * 业务接口
 * 跟进记录表
 * </p>
 *
 * @author clm
 * @date 2022 -06-11
 */
public interface FollowRecordService extends SuperService<FollowRecord> {

    /**
     * 保存跟进记录.
     *
     * @param saveDTO the save dto
     * @return the boolean
     */
    boolean saveFollowRecordPlan(FollowRecordPlanSaveDTO saveDTO);

    /**
     * 查询跟进记录列表.
     *
     * @param query the query
     * @return the list
     */
    List<FollowRecordVO> listFollowRecords(FollowRecordQuery query);

    /**
     * 查询跟进记录时间轴.
     *
     * @param query the next start time
     * @return the r
     */
    R<List<FollowRecordTimelineVO>> listFollowRecordTimelineVOs(FollowRecordTimelineQuery query);

    /**
     * 统计跟进记录数量.
     *
     * @param customerId the customer id
     * @return the long
     */
    long countFollowRecordByCustomerId(Long customerId);

    /**
     * 获取最后跟进时间.
     *
     * @param followDateTime the follow date time
     * @param lastFollowDate the last follow date
     * @return the last follow date
     */
    static LocalDateTime getLastFollowDate(LocalDateTime followDateTime, LocalDateTime lastFollowDate) {
        if (lastFollowDate == null) {
            return followDateTime;
        }
        if (followDateTime == null) {
            return null;
        }
        return lastFollowDate.isAfter(followDateTime) ? lastFollowDate : followDateTime;
    }

    /**
     * @Author clm
     * @Description //获取未同步的跟进记录
     * @Date 10:10 2023/2/1
     * @Param []
     * @return com.eastfair.core.base.R<java.util.List<com.eastfair.venuebooking.vo.FollowRecordTimelineVO>>
     **/
    List<FollowRecordVO> listUnsynRecord();
}
